package hichecker.tools.export;

import java.util.ArrayList;
import java.util.List;

public class CSVFile {
	private String name;
	private int cols;
	private List<String> lines;

	public CSVFile(String name, int cols) {
		this.name = name;
		this.cols = cols;
		lines = new ArrayList<String>();
	}

	public void addLine(String[] values) {
		if (values.length != cols)
			throw new IllegalArgumentException(cols + " values expected");

		String line = "";
		for (int i = 0; i < values.length; i++)
			line += "\"" + values[i] + "\";";
		line = line.substring(0, line.length() - 1);
		lines.add(line);
	}

	public String getName() {
		return name;
	}

	@Override
	public String toString() {
		String s = "";
		for (String line : lines)
			s += line + "\n";
		return s;
	}
}
